commonlibsse_ng\re\n/
NiObject.rs1use crate::re::NiRTTI::NiRTTI;
2use crate::re::NiRefObject::NiRefObject;
3use crate::re::NiRefObject::NiRefObjectVtbl;
4use crate::re::NiSmartPointer::NiPointer;
5use crate::re::offsets_ni_rtti::NiRTTI_NiObject;
6use crate::re::offsets_rtti::RTTI_NiObject;
7use crate::re::offsets_vtable::VTABLE_NiObject;
8use crate::re::{
9 BSDynamicTriShape, BSFadeNode, BSGeometry, BSLines, BSMultiBoundNode, BSSegmentedTriShape,
10 BSSubIndexTriShape, BSTriShape, NiCloningProcess, NiControllerManager, NiGeometry, NiNode,
11 NiObjectGroup, NiParticles, NiStream, NiSwitchNode, NiTriBasedGeom, NiTriShape, NiTriStrips,
12 bhkAttachmentCollisionObject, bhkBlendCollisionObject, bhkLimitedHingeConstraint,
13 bhkNiCollisionObject, bhkRigidBody,
14};
15use crate::rel::ResolvableAddress as _;
16use crate::rel::id::{DataBaseError, VariantID};
17use crate::rel::relocation::Relocation;
18use core::ffi::CStr;
19use core::ptr::NonNull;
20
21#[repr(C)]
22#[derive(Debug)]
23pub struct NiObject {
24 pub __base: NiRefObject,
25}
26const _: () = assert!(core::mem::size_of::<NiObject>() == 0x10);
27
28impl NiObject {
29 pub const RTTI: VariantID = RTTI_NiObject;
30 pub const NI_RTTI: VariantID = NiRTTI_NiObject;
31 pub const VTABLE: [VariantID; 1] = VTABLE_NiObject;
32
33 pub fn get_rtti(&self) -> Result<NonNull<NiRTTI>, DataBaseError> {
35 let rel = Relocation::new(Self::NI_RTTI.address()?);
36 Ok(rel.cast::<NiRTTI>())
37 }
38
39 pub unsafe fn is_equal(&self, other: *mut Self) -> bool {
41 if other.is_null() {};
42
43 let name = match self.get_rtti() {
44 Ok(rtti) => unsafe { rtti.as_ref().get_name() },
45 Err(_) => return false,
46 };
47 let rtti = match unsafe { other.as_ref() } {
48 Some(rtti) => rtti,
49 None => return false,
50 };
51
52 let rtti = match rtti.get_rtti() {
53 Ok(rtti) => rtti,
54 Err(_) => return false,
55 };
56 let other_name = unsafe { rtti.as_ref().get_name() };
57 let self_name = unsafe { CStr::from_ptr(name) };
58 let other_name = unsafe { CStr::from_ptr(other_name) };
59 self_name == other_name
60 }
61
62 #[commonlibsse_ng_derive_internal::relocate_fn(se_id = 68838, ae_id = 70190)]
63 pub unsafe fn process_clone(&self, cloning: &NiCloningProcess) {}
64
65 #[commonlibsse_ng_derive_internal::relocate_fn(se_id = 68839, ae_id = 70191)]
66 pub unsafe fn create_deep_copy(&self, cloning: &NiPointer<NiObject>) {}
67}
68
69impl crate::re::NiSmartPointer::RefCountable for NiObject {
70 #[inline]
71 fn inc_ref_count(&self) {
72 self.__base.inc_ref_count();
73 }
74
75 #[inline]
76 fn dec_ref_count(&mut self) {
77 self.__base.dec_ref_count();
78 }
79}
80
81#[repr(C)]
85pub struct NiObjectVtbl {
86 pub __base: NiRefObjectVtbl,
90
91 pub GetRtti: unsafe extern "C" fn(this: *const NiObject) -> *const NiRTTI, pub AsNode: unsafe extern "C" fn(this: *mut NiObject) -> *mut NiNode, pub AsSwitchNode: unsafe extern "C" fn(this: *mut NiObject) -> *mut NiSwitchNode, pub AsFadeNode: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSFadeNode, pub AsMultiBoundNode: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSMultiBoundNode, pub AsGeometry: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSGeometry, pub AsTriStrips: unsafe extern "C" fn(this: *mut NiObject) -> *mut NiTriStrips, pub AsTriShape: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSTriShape, pub AsSegmentedTriShape: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSSegmentedTriShape, pub AsSubIndexTriShape: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSSubIndexTriShape, pub AsDynamicTriShape: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSDynamicTriShape, pub AsNiGeometry: unsafe extern "C" fn(this: *mut NiObject) -> *mut NiGeometry, pub AsNiTriBasedGeom: unsafe extern "C" fn(this: *mut NiObject) -> *mut NiTriBasedGeom, pub AsNiTriShape: unsafe extern "C" fn(this: *mut NiObject) -> *mut NiTriShape, pub AsParticlesGeom: unsafe extern "C" fn(this: *mut NiObject) -> *mut NiParticles, pub AsLinesGeom: unsafe extern "C" fn(this: *mut NiObject) -> *mut BSLines, pub AsBhkNiCollisionObject:
109 unsafe extern "C" fn(this: *mut NiObject) -> *mut bhkNiCollisionObject, pub AsBhkBlendCollisionObject:
111 unsafe extern "C" fn(this: *mut NiObject) -> *mut bhkBlendCollisionObject, pub AsBhkAttachmentCollisionObject:
113 unsafe extern "C" fn(this: *mut NiObject) -> *mut bhkAttachmentCollisionObject, pub AsBhkRigidBody: unsafe extern "C" fn(this: *mut NiObject) -> *mut bhkRigidBody, pub AsBhkLimitedHingeConstraint:
116 unsafe extern "C" fn(this: *mut NiObject) -> *mut bhkLimitedHingeConstraint, pub CreateClone:
118 unsafe extern "C" fn(this: *mut NiObject, cloning: *mut NiCloningProcess) -> *mut NiObject, pub LoadBinary: unsafe extern "C" fn(this: *mut NiObject, stream: *mut NiStream), pub LinkObject: unsafe extern "C" fn(this: *mut NiObject, stream: *mut NiStream), pub RegisterStreamables:
122 unsafe extern "C" fn(this: *mut NiObject, stream: *mut NiStream) -> bool, pub SaveBinary: unsafe extern "C" fn(this: *mut NiObject, stream: *mut NiStream), pub IsEqual: unsafe extern "C" fn(this: *mut NiObject, other: *mut NiObject) -> bool, pub ProcessClone: unsafe extern "C" fn(this: *mut NiObject, cloning: *mut NiCloningProcess), pub PostLinkObject: unsafe extern "C" fn(this: *mut NiObject, stream: *mut NiStream), pub StreamCanSkip: unsafe extern "C" fn(this: *mut NiObject) -> bool, pub GetStreamableRtti: unsafe extern "C" fn(this: *const NiObject) -> *const NiRTTI, pub GetBlockAllocationSize: unsafe extern "C" fn(this: *const NiObject) -> u32, pub GetGroup: unsafe extern "C" fn(this: *const NiObject) -> *mut NiObjectGroup, pub SetGroup: unsafe extern "C" fn(this: *mut NiObject, group: *mut NiObjectGroup), pub AsNiControllerManager:
134 unsafe extern "C" fn(this: *mut NiObject) -> *mut NiControllerManager, }
136const _: () = {
137 const FN_COUNT: usize = 37 * core::mem::size_of::<usize>();
138 assert!(core::mem::size_of::<NiObjectVtbl>() == FN_COUNT);
139};